#!/usr/bin/python
# -*- coding: UTF-8 -*-
# Copyright (c) 2014,OpenThings Projects.
# 通过串口进行WiFi模块参数配置，需要USB转TTL连接模块。

import sys
import os
import time
import serial 

portDevice = '/dev/ttyUSB0'		#Arduino连接的端口。
baudrate = 9600

AP = "NETGEAR71"				#无线接入点SSID。
PWD = "shinyphoenix155"			#密码。
portIPServer = 8888				#模块IP服务器的端口。
SrvClient = "192.168.199.199"	#客户端连接的远程地址。
portClient = 9999				#客户端连接的远程端口。

#while True: 
print "WiFi AT Configuration Tool. V1.0"
print "Created by OpenThings Project,2014-09-29."

def GetResult():
	while (ser.inWaiting()>0)
		sData = ser.readline()
		print sData

ser = serial.Serial(portDevice,baudrate)
ser.writeline("@")

ser.writeline("@CWJAP="+"\""+AP+"\","+"\""+PWD+"\"")
ser.writeline("@CIPMUX=1")
ser.writeline("@CIPSERVER=1,"+portIPServer)
ser.writeline("@CIFSR")

#ser.writeline("@CIPSTART=")
#ser.writeline("@CIFSR")

ser.close()
print "Serial port closed."


